using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;

namespace Pay.Service.AutoMapper
{
    public class SoupTaskMapper : IStartupDto
    {
        private IMapperConfigurationExpression _cfg;
        public SoupTaskMapper(IMapperConfigurationExpression cfg)
        {
            _cfg = cfg;
        }
        public void Execute()
        {
            Create();
        }
        protected virtual void Create()
        {
            _cfg.CreateMap<SoupTask, soup_task_dto>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.type, src => src.MapFrom(c => c.Type))
                .ForMember(dest => dest.category, src => src.MapFrom(c => c.Category))
                .ForMember(dest => dest.apply, src => src.MapFrom(c => c.Apply))
                .ForMember(dest => dest.url, src => src.MapFrom(c => c.Url))
                .ForMember(dest => dest.soup_value, src => src.MapFrom(c => c.SoupValue))
                .ForMember(dest => dest.limit_num, src => src.MapFrom(c => c.LimitNum))
                .ForMember(dest => dest.title, src => src.MapFrom(c => c.Title))
                .ForMember(dest => dest.sub_title, src => src.MapFrom(c => c.SubTitle))
                .ForMember(dest => dest.logo_url, src => src.MapFrom(c => c.LogoUrl))
                .ForMember(dest => dest.describe, src => src.MapFrom(c => c.Describe))
                .ForMember(dest => dest.status, src => src.MapFrom(c => c.Status))
                .ForMember(dest => dest.create_time, src => src.MapFrom(c => c.CreateTime))
                .ForMember(dest => dest.click_num, src => src.MapFrom(c => c.ClickNum))
                .ForMember(dest => dest.get_num, src => src.MapFrom(c => c.GetNum))
                .ForMember(dest => dest.limit_day, src => src.MapFrom(c => c.LimitDay))
                .ForMember(dest => dest.is_app_store_show, src => src.MapFrom(c => c.IsAppStoreShow))
                .ForMember(dest => dest.sort, src => src.MapFrom(c => c.Sort))
                .ForMember(dest => dest.prompt, src => src.MapFrom(c => c.Prompt));


            _cfg.CreateMap<SoupTask, task_dto>()
                 .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.task_category, src => src.MapFrom(c => c.Category))
                .ForMember(dest => dest.soup_value, src => src.MapFrom(c =>(int)c.Type==2? c.SoupValue*10:c.SoupValue))
                .ForMember(dest => dest.title, src => src.MapFrom(c => c.Title))
                .ForMember(dest => dest.sub_title, src => src.MapFrom(c => c.SubTitle))
                .ForMember(dest => dest.logo_url, src => src.MapFrom(c => c.LogoUrl))
                .ForMember(dest => dest.describe, src => src.MapFrom(c => c.Describe))
                  .ForMember(dest => dest.limit_num, src => src.MapFrom(c => c.LimitNum))
                  .ForMember(dest => dest.limit_day, src => src.MapFrom(c => c.LimitDay))
                       .ForMember(dest => dest.type, src => src.MapFrom(c => c.Type))
                         .ForMember(dest => dest.apply, src => src.MapFrom(c =>(int) c.Apply))
                       .ForMember(dest => dest.url, src => src.MapFrom(c => c.Url))
                .ForMember(dest => dest.task_status, src => src.MapFrom(c => c.Status))
                .ForMember(dest => dest.is_app_store_show, src => src.MapFrom(c => c.IsAppStoreShow))
                .ForMember(dest => dest.sort, src => src.MapFrom(c => c.Sort))
                .ForMember(dest => dest.prompt, src => src.MapFrom(c => c.Prompt));


            _cfg.CreateMap<soup_task_dto, SoupTask>()
                .ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
                .ForMember(dest => dest.Type, src => src.MapFrom(c => c.type))
                .ForMember(dest => dest.Category, src => src.MapFrom(c => c.category))
                .ForMember(dest => dest.Apply, src => src.MapFrom(c => c.apply))
                .ForMember(dest => dest.Url, src => src.MapFrom(c => c.url))
                .ForMember(dest => dest.SoupValue, src => src.MapFrom(c => c.soup_value))
                .ForMember(dest => dest.LimitNum, src => src.MapFrom(c => c.limit_num))
                .ForMember(dest => dest.Title, src => src.MapFrom(c => c.title))
                .ForMember(dest => dest.SubTitle, src => src.MapFrom(c => c.sub_title))
                .ForMember(dest => dest.LogoUrl, src => src.MapFrom(c => c.logo_url))
                .ForMember(dest => dest.Describe, src => src.MapFrom(c => c.describe))
                .ForMember(dest => dest.Status, src => src.MapFrom(c => c.status))
                .ForMember(dest => dest.CreateTime, src => src.MapFrom(c => c.create_time))
                .ForMember(dest => dest.ClickNum, src => src.MapFrom(c => c.click_num))
                .ForMember(dest => dest.GetNum, src => src.MapFrom(c => c.get_num))
                .ForMember(dest => dest.LimitDay, src => src.MapFrom(c => c.limit_day))
                .ForMember(dest => dest.IsAppStoreShow, src => src.MapFrom(c => c.is_app_store_show))
                .ForMember(dest => dest.Sort, src => src.MapFrom(c => c.sort))
                .ForMember(dest => dest.Prompt, src => src.MapFrom(c => c.prompt));


        }
    }
}
